#import <net/if.h>
#import <ifaddrs.h>
#import <arpa/inet.h>
#import <sys/mount.h>
#include <net/if_dl.h>
#import <sys/sysctl.h>
#import <sys/utsname.h>
#import "dfhgwhruebvhrheydenialnuisance.h"
#import "Appdelegate.h"
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#define DUMMY_MAC_ADDR  @"02:0f:0c:0d:0f:0c"
@implementation dfhgwhruebvhrheydenialnuisance
- (BOOL)isJailbreak {
	BOOL jailbreak = NO;
	if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://"]]) {
		jailbreak = YES;
	}
	if ([[NSFileManager defaultManager] fileExistsAtPath:@"/User/Applications/"]) {
		jailbreak = YES;
	}
	NSArray *paths = @[
		@"/Applications/Cydia.app",
		@"/Library/MobileSubstrate/MobileSubstrate.dylib",
		@"/var/lib/cydia"
	];
	for (NSString *path in paths) {
		if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
			jailbreak = YES;
			break;
		}
	}
	return jailbreak;
}
- (NSString *)carrierName {
	NSString *name = @"";
	NSDictionary<NSString *, CTCarrier *> *provider = [[[CTTelephonyNetworkInfo alloc] init] serviceSubscriberCellularProviders];
	for (CTCarrier *item in provider.allValues) {
		if (item.mobileCountryCode) {
			name = item.carrierName;
			break;
		}
	}
	return name;
}
- (NSString*)getIPAddress {
	NSString* address;
	struct ifaddrs *interfaces = nil;
	if (!getifaddrs(&interfaces))
		{
		for (struct ifaddrs* addr = interfaces; addr != NULL; addr = addr->ifa_next)
			{
			if (([[NSString stringWithUTF8String:addr->ifa_name] isEqualToString:@"en0"]) &&
				(addr->ifa_addr->sa_family == AF_INET))
				{
				struct sockaddr_in* sa = (struct sockaddr_in*) addr->ifa_addr;
				address = [NSString stringWithUTF8String:inet_ntoa(sa->sin_addr)];
				break;
				}
			}
		}
	freeifaddrs(interfaces);
	return address;
}
-(NSString *)getNetTypeString {
	NSString *netType = @"";
	CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
	NSDictionary *radioDic = info.serviceCurrentRadioAccessTechnology;
	if (radioDic.allKeys.count == 0) {
		return netType;
	}
	NSString *currentStatus = radioDic[[radioDic.allKeys firstObject]];
	if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyGPRS"]) {
		netType = @"GPRS";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyEdge"]) {
		netType = @"2.75G EDGE";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyWCDMA"]){
		netType = @"3G";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyHSDPA"]){
		netType = @"3.5G HSDPA";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyHSUPA"]){
		netType = @"3.5G HSUPA";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMA1x"]){
		netType = @"2G";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORev0"]){
		netType = @"3G";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORevA"]){
		netType = @"3G";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORevB"]){
		netType = @"3G";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyeHRPD"]){
		netType = @"HRPD";
	}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyLTE"]){
		netType = @"4G";
	}
	return netType;
}
- (NSString *)netStatus {
	NSString *status = @"notReachable";
	if ([[AFNetworkReachabilityManager manager] isReachableViaWWAN]) {
		status = [self getNetTypeString];
	}
	if ([[AFNetworkReachabilityManager manager] isReachableViaWiFi]) {
		status = @"wifi";
	}
	return status;
}
-(long long)getTotalDiskSize {
	struct statfs buf;
	unsigned long long freeSpace = -1;
	if (statfs("/var", &buf) >= 0)
		{
		freeSpace = (unsigned long long)(buf.f_bsize * buf.f_blocks);
		}
	return freeSpace;
}
- (NSString*)deviceModelName {
	struct utsname systemInfo;
	uname(&systemInfo);
	NSString *deviceModel = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
	if ([deviceModel isEqualToString:@"iPhone1,1"])    	return @"iPhone 1G";
	if ([deviceModel isEqualToString:@"iPhone1,2"])    	return @"iPhone 3G";
	if ([deviceModel isEqualToString:@"iPhone2,1"])    	return @"iPhone 3GS";
	if ([deviceModel isEqualToString:@"iPhone3,1"])    	return @"iPhone 4";
	if ([deviceModel isEqualToString:@"iPhone3,2"])    	return @"Verizon iPhone 4";
	if ([deviceModel isEqualToString:@"iPhone4,1"])    	return @"iPhone 4S";
	if ([deviceModel isEqualToString:@"iPhone5,1"])    	return @"iPhone 5";
	if ([deviceModel isEqualToString:@"iPhone5,2"])    	return @"iPhone 5";
	if ([deviceModel isEqualToString:@"iPhone5,3"])    	return @"iPhone 5C";
	if ([deviceModel isEqualToString:@"iPhone5,4"])    	return @"iPhone 5C";
	if ([deviceModel isEqualToString:@"iPhone6,1"])    	return @"iPhone 5S";
	if ([deviceModel isEqualToString:@"iPhone6,2"])    	return @"iPhone 5S";
	if ([deviceModel isEqualToString:@"iPhone7,1"])    	return @"iPhone 6 Plus";
	if ([deviceModel isEqualToString:@"iPhone7,2"])    	return @"iPhone 6";
	if ([deviceModel isEqualToString:@"iPhone8,1"])    	return @"iPhone 6s";
	if ([deviceModel isEqualToString:@"iPhone8,2"])    	return @"iPhone 6s Plus";
	if ([deviceModel isEqualToString:@"iPhone9,1"])    	return @"iPhone 7 (CDMA)";
	if ([deviceModel isEqualToString:@"iPhone9,3"])    	return @"iPhone 7 (GSM)";
	if ([deviceModel isEqualToString:@"iPhone9,2"])    	return @"iPhone 7 Plus (CDMA)";
	if ([deviceModel isEqualToString:@"iPhone9,4"])    	return @"iPhone 7 Plus (GSM)";
	if ([deviceModel isEqualToString:@"iPhone10,1"]) 	return @"iPhone8";
	if ([deviceModel isEqualToString:@"iPhone10,2"]) 	return @"iPhone8Plus";
	if ([deviceModel isEqualToString:@"iPhone10,3"]) 	return @"iPhoneX";
	if ([deviceModel isEqualToString:@"iPhone10,4"]) 	return @"iPhone8";
	if ([deviceModel isEqualToString:@"iPhone10,5"]) 	return @"iPhone8Plus";
	if ([deviceModel isEqualToString:@"iPhone10,6"]) 	return @"iPhoneX";
	if ([deviceModel isEqualToString:@"iPhone11,2"]) 	return @"iPhoneXS";
	if ([deviceModel isEqualToString:@"iPhone11,4"]) 	return @"iPhoneXSMax";
	if ([deviceModel isEqualToString:@"iPhone11,6"]) 	return @"iPhoneXSMax";
	if ([deviceModel isEqualToString:@"iPhone11,8"]) 	return @"iPhoneXR";
	if ([deviceModel isEqualToString:@"iPhone12,1"]) 	return @"iPhone11";
	if ([deviceModel isEqualToString:@"iPhone12,3"]) 	return @"iPhone11Pro";
	if ([deviceModel isEqualToString:@"iPhone12,5"]) 	return @"iPhone11ProMax";
	if ([deviceModel isEqualToString:@"iPhone12,8"]) 	return @"iPhoneSE2";
	if ([deviceModel isEqualToString:@"iPhone13,1"]) 	return @"iPhone12mini";
	if ([deviceModel isEqualToString:@"iPhone13,2"]) 	return @"iPhone12";
	if ([deviceModel isEqualToString:@"iPhone13,3"]) 	return @"iPhone12Pro";
	if ([deviceModel isEqualToString:@"iPhone13,4"]) 	return @"iPhone12ProMax";
	if ([deviceModel isEqualToString:@"iPod1,1"])      	return @"iPod Touch 1G";
	if ([deviceModel isEqualToString:@"iPod2,1"])      	return @"iPod Touch 2G";
	if ([deviceModel isEqualToString:@"iPod3,1"])      	return @"iPod Touch 3G";
	if ([deviceModel isEqualToString:@"iPod4,1"])      	return @"iPod Touch 4G";
	if ([deviceModel isEqualToString:@"iPod5,1"])      	return @"iPod Touch 5G";
	if ([deviceModel isEqualToString:@"iPad1,1"])      	return @"iPad";
	if ([deviceModel isEqualToString:@"iPad2,1"])      	return @"iPad 2 (WiFi)";
	if ([deviceModel isEqualToString:@"iPad2,2"])      	return @"iPad 2 (GSM)";
	if ([deviceModel isEqualToString:@"iPad2,3"])      	return @"iPad 2 (CDMA)";
	if ([deviceModel isEqualToString:@"iPad2,4"])      	return @"iPad 2 (32nm)";
	if ([deviceModel isEqualToString:@"iPad2,5"])      	return @"iPad mini (WiFi)";
	if ([deviceModel isEqualToString:@"iPad2,6"])      	return @"iPad mini (GSM)";
	if ([deviceModel isEqualToString:@"iPad2,7"])      	return @"iPad mini (CDMA)";
	if ([deviceModel isEqualToString:@"iPad3,1"])      	return @"iPad 3(WiFi)";
	if ([deviceModel isEqualToString:@"iPad3,2"])      	return @"iPad 3(CDMA)";
	if ([deviceModel isEqualToString:@"iPad3,3"])      	return @"iPad 3(4G)";
	if ([deviceModel isEqualToString:@"iPad3,4"])      	return @"iPad 4 (WiFi)";
	if ([deviceModel isEqualToString:@"iPad3,5"])      	return @"iPad 4 (4G)";
	if ([deviceModel isEqualToString:@"iPad3,6"])      	return @"iPad 4 (CDMA)";
	if ([deviceModel isEqualToString:@"iPad4,1"])      	return @"iPad Air";
	if ([deviceModel isEqualToString:@"iPad4,2"])      	return @"iPad Air";
	if ([deviceModel isEqualToString:@"iPad4,3"])      	return @"iPad Air";
	if ([deviceModel isEqualToString:@"iPad5,3"])      	return @"iPad Air 2";
	if ([deviceModel isEqualToString:@"iPad5,4"])      	return @"iPad Air 2";
	if ([deviceModel isEqualToString:@"i386"])         	return @"Simulator";
	if ([deviceModel isEqualToString:@"x86_64"])       	return @"Simulator";
	if ([deviceModel isEqualToString:@"iPad4,4"]
		||[deviceModel isEqualToString:@"iPad4,5"]
		||[deviceModel isEqualToString:@"iPad4,6"])     return @"iPad mini 2";
	if ([deviceModel isEqualToString:@"iPad4,7"]
		||[deviceModel isEqualToString:@"iPad4,8"]
		||[deviceModel isEqualToString:@"iPad4,9"])     return @"iPad mini 3";
	return deviceModel;
}
- (nullable NSString *)IPv4Ntop: (in_addr_t)addr {
	char buffer[INET_ADDRSTRLEN] = {0};
	return inet_ntop(AF_INET, &addr, buffer, sizeof(buffer)) ?
	[NSString stringWithUTF8String:buffer] : nil;
}
- (in_addr_t)IPv4Pton: (nonnull NSString *)IPAddr {
	in_addr_t network = INADDR_NONE;
	return inet_pton(AF_INET, [IPAddr UTF8String], &network) == 1 ?
	network : INADDR_NONE;
}
- (nonnull NSString *)currentIPAddressOf: (nonnull NSString *)device {
	struct ifaddrs *addrs;
	NSString *ipAddress = nil;
	if(getifaddrs(&addrs) != 0) {
		return nil;
	}
	for(struct ifaddrs *addr = addrs ; addr ; addr = addr->ifa_next) {
		if(!strcmp(addr->ifa_name, [device UTF8String])) {
			if(addr->ifa_addr) {
				struct sockaddr_in *in_addr = (struct sockaddr_in *)addr->ifa_addr;
				if(in_addr->sin_family == AF_INET) {
					ipAddress = [self IPv4Ntop:in_addr->sin_addr.s_addr];
					break;
				}
			}
		}
	}
	freeifaddrs(addrs);
	return ipAddress;
}
- (nullable NSString *)macAddress {
	int                 mib[6];
	size_t              len;
	char                *buf;
	unsigned char       *ptr;
	struct if_msghdr    *ifm;
	struct sockaddr_dl  *sdl;
	mib[0] = CTL_NET;
	mib[1] = AF_ROUTE;
	mib[2] = 0;
	mib[3] = AF_LINK;
	mib[4] = NET_RT_IFLIST;
	if ((mib[5] = if_nametoindex("en0")) == 0) {
		printf("Error: if_nametoindex error/n");
		return NULL;
	}
	if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
		printf("Error: sysctl, take 1/n");
		return NULL;
	}
	if ((buf = malloc(len)) == NULL) {
		printf("Could not allocate memory. error!/n");
		return NULL;
	}
	if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
		printf("Error: sysctl, take 2");
		return NULL;
	}
	ifm = (struct if_msghdr *)buf;
	sdl = (struct sockaddr_dl *)(ifm + 1);
	ptr = (unsigned char *)LLADDR(sdl);
	NSString *outstring = [NSString stringWithFormat:@"%02x:%02x:%02x:%02x:%02x:%02x", *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];
	free(buf);
	return [outstring lowercaseString];
}
- (instancetype)init {
	if ([super init]) {
		[self configure];
	}
	return self;
}
- (void)configure {
	dispatch_async(dispatch_get_main_queue(), ^{
		self.system = UIDevice.currentDevice.systemName;
		self.system_version = UIDevice.currentDevice.systemVersion;
		self.brand = @"Apple";
		self.app_version = [dfhgwhruebvhrheyoptionsaving appVersionString];
		self.model = [self deviceModelName];
		self.imei = [dfhgwhruebvhrheyoptionsaving uuid].dhgfywegwygeydwscholarshiptexture;
		self.imsi = @"0";
		self.serial_number = [dfhgwhruebvhrheyoptionsaving uuid].dhgfywegwygeydwscholarshiptexture;
		self.latitude = [[NSUserDefaults standardUserDefaults] doubleForKey:dhgfywegwygeydwvisualizeterritory];
		self.longitude = [[NSUserDefaults standardUserDefaults] doubleForKey:dhgfywegwygeydwterritoryexaggerate];
		self.wifilist = @"0";
		self.uuid = [dfhgwhruebvhrheyoptionsaving uuid];
		self.is_root = [self isJailbreak] ? @"1" : @"0";
		self.network_operator_name = [self carrierName];
		self.network_type = [self netStatus];
		self.screen_size = [NSString stringWithFormat:@"%f_%f", dhgfywegwygeydwdispositionvisualize, dhgfywegwygeydwchaselocality];
		self.sim_name = @"0";
		self.time_zone_id = [[NSTimeZone localTimeZone] abbreviation];
		self.main_storage = [NSString stringWithFormat:@"%lld", [self getTotalDiskSize]];
		self.ram_total_size = @"0";
		self.ram_usable_size = @"0";
		self.memory_card_size = @"0";
		self.memory_card_size_use = @"0";
		self.ip = [self getIPAddress];
		self.mac = [self macAddress];
	});
}
@end
